package com.hc.oa.assertion.dao;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.hibernate.annotations.common.util.StringHelper;
import org.springframework.stereotype.Repository;

import com.bstek.dorado.data.provider.Page;
import com.hc.oa.common.*;
import com.hc.oa.model.Assertion;
import com.hc.oa.model.Bdf2Assertion;

@Repository
public class AssertionDao extends HibernateUtilDao<Bdf2Assertion>{
	
	public void queryAllByAssertPage(Page<Bdf2Assertion> page,Class cls,Map parameter) throws Exception{
	    Map<String,Object> map =new HashMap<String,Object>();
	    String sql="from "+cls.getName()+" du ";
	    String sqlCount="select count(*) from "+cls.getName()+" du ";
	    sql+=" where 1=1 ";
	    sqlCount+=" where 1=1 ";
	    if(parameter!=null){
	    	String Assert_name = (String)parameter.get("Assert_name");
	    	if (Assert_name != null && !"".equals(Assert_name)){
	    		map.put("Assert_name", parameter.get("Assert_name"));
	    		sql+=" and du.Assert_name=:Assert_name";
	    		sqlCount+=" and du.Assert_name=:Assert_name";
	    	}
	    	String Assert_people = (String)parameter.get("Assert_people");
	    	if (Assert_people != null && !"".equals(Assert_people)){
	    		map.put("Assert_people", parameter.get("Assert_people"));
	    		sql+=" and du.Assert_people=:Assert_people";
	    		sqlCount+=" and du.Assert_people=:Assert_people";
	    	}
	    	String Assert_status = (String)parameter.get("Assert_status");
	    	if (Assert_status != null && !"".equals(Assert_status)){
	    		map.put("Assert_status", parameter.get("Assert_status"));
	    		sql+=" and du.Assert_status=:Assert_status";
	    		sqlCount+=" and du.Assert_status=:Assert_status";
	    	}
	    	String Assert_type = (String)parameter.get("Assert_type");
	    	if (Assert_type != null && !"".equals(Assert_type)){
	    		map.put("Assert_type", parameter.get("Assert_type"));
	    		sql+=" and du.Assert_type=:Assert_type";
	    		sqlCount+=" and du.Assert_type=:Assert_type";
	    	}
	    	String Assert_inputpeople = (String)parameter.get("Assert_inputpeople");
	    	if (Assert_inputpeople != null && !"".equals(Assert_inputpeople)){
	    		map.put("Assert_inputpeople", parameter.get("Assert_inputpeople"));
	    		sql+=" and du.Assert_inputpeople=:Assert_inputpeople";
	    		sqlCount+=" and du.Assert_inputpeople=:Assert_inputpeople";
	    	}
	    	 Date Assert_inputdate = (Date) parameter.get("Assert_inputdate");
	    	 if (Assert_inputdate != null && !"".equals(Assert_inputdate)){
		    		map.put("Assert_inputdate", parameter.get("Assert_inputdate"));
		    		sql+=" and du.Assert_inputdate=:Assert_inputdate";
		    		sqlCount+=" and du.Assert_inputdate=:Assert_inputdate";
		    }
	    	 Date Assert_returndate = (Date) parameter.get("Assert_returndate");
	    	 if (Assert_returndate != null && !"".equals(Assert_returndate)){
		    		map.put("Assert_returndate", parameter.get("Assert_returndate"));
		    		sql+=" and du.Assert_returndate=:Assert_returndate";
		    		sqlCount+=" and du.Assert_returndate=:Assert_returndate";
		    }
	    }
	    this.pagingQuery(page, sql,sqlCount,map);
	}

}
